<style lang="stylus" scoped>
    /* 隐藏滚动条 */
    html,body::-webkit-scrollbar {
        display: none;
    }
    .element::-webkit-scrollbar {display:none}
    .detail::-webkit-scrollbar {
        display: none;
    }
    /* 标题 */
    .title{
      font-size:17px;
      font-family:'SourceHanSansCN-Medium';
      font-weight:600;
      color:rgba(39,37,37,1);
      line-height:35px;
      height:35px;
      z-index: 30000;
    }

    /* 轮播图 */
  .swiper-container {
    width: 100% !important;
    height: 100% !important;
    margin: 0 auto;
    /* padding-bottom: 15px !important; */
  }
  /* 单个盒子 */
  .swiper-slide {
    width: 100% !important;
    height: 375px !important;
  }
  /* 图片样式 */
  .swiper-slide img {
    height: 100% !important;
    width: 100% !important;
  }
  /*包裹自定义分页器的div的位置等CSS样式*/
  .swiper-pagination-custom {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
  }
  /*自定义分页器的样式*/
  .swiper-pagination-customs {
    display: inline-block !important;
    opacity: 0.3 !important;
    width: 6px  !important;
    height: 6px  !important;
    background: rgba(255, 137, 156, 1)  !important;
    border-radius: 3px  !important;
    margin: 0 5px  !important;
  }
  /*激活时的样式*/
  .swiper-pagination-customs-active {
    opacity: 1 !important;
    background: rgba(255, 137, 156, 1) !important;
    width: 10px !important;
  }
  .swiper-container-3d .swiper-slide-shadow-left {
    background-image:none !important
  }
  .swiper-container-3d .swiper-slide-shadow-right {
    background-image:none !important
  }
  .bottom-box{
    position: fixed;
    left: 0;
    bottom: 0;
    /* bottom: 20px; */
    background: rgba(255,255,255,1);
    width:100%;
    height: 44px;
    /* height: 100px; */

  }
  .bottom-box-20{
    bottom: 20px !important;
    transition: bottom 1s
  }

  .buy{
    line-height: 44px;
    font-size:14px;
    font-family:'SourceHanSansCN-Medium';
    font-weight:500;
    color:rgba(255,255,255,1);
    background:rgba(255,161,176,1);
  }
  .transfer{
    line-height: 44px;
    font-size:14px;
    font-family:'SourceHanSansCN-Medium';
    font-weight:500;
    color:rgba(255,255,255,1);
    background:rgba(255,194,204,1);
  }
  .shipment{
    line-height: 44px;
    font-size:14px;
    font-family:'SourceHanSansCN-Medium';
    font-weight:500;
    color:rgba(255,255,255,1);
    background:rgba(255,161,176,1);
  }
  .mylist{
    padding-top:3px;
    text-align: center;
    font-size:10px;
    font-family:'SourceHanSansCN-Regular';
    font-weight:400;
    color:rgba(102,99,99,1);
  }
  .mylist p{
    font-size:10px;
  }
  .msg{
    background:rgba(255,255,255,1);
    padding:15px;
    margin-bottom: 10px;
  }
  .msg>p:nth-of-type(1){
    margin: 8px 0 5px;
    font-size:14px;
    font-family:'SourceHanSansCN-Medium';
    font-weight:600;
    color:rgba(25,25,25,1);
    line-height:18px;
  }
  .msg>p:nth-of-type(2){
    font-size:12px;
    font-family:'SourceHanSansCN-Regular';
    font-weight:400;
    color:rgba(102,102,102,1);
    line-height:17px;
  }
  .price>span:nth-child(1){
    font-size:21px;
    font-family:'DIN-Bold';
    font-weight:bold;
    color:rgba(255,161,176,1);
    padding-right: 15px;
  }
  .price>span:nth-child(2){
    font-size:12px;
    font-family:'SourceHanSansCN-Regular';
    font-weight:400;
    text-decoration:line-through;
    color:rgba(153,153,153,1);
  }
  .stock span{
    flex:1;
    font-size:10px;
    font-family:'SourceHanSansCN-Regular';
    font-weight:400;
    color:rgba(153,153,153,1);
    text-align: right;
  }
  .goods_title{
    width: 100%;
    height: 60px;
    background: rgba(255,255,255,1);
    line-height: 60px;
    padding-left:15px;
    font-size:15px;
    font-family:'SourceHanSansCN-Medium';
    font-weight:600;
    color:rgba(25,25,25,1);
  }
  .detail {
      padding: 0 15px 50px;
      background: rgba(255,255,255,1);
    }
    .banner-icon{
      left: 50%;bottom: 10px;
      transform: translateX(-50%);
      background: #000;
      opacity: 0.3;
      padding:2px 10px;
      border-radius: 10px;
      font-size:10px;
      font-family:'SourceHanSansCN-Regular';
      font-weight:400;
      color:rgba(254,254,254,1);
    }
    .banner-btn{
      width: 40px;height: 40px;
      right: 15px;bottom: 15px;
    }
    .fly-ball{
      /* width: 20px;
      height: 20px; */
      /* background:rgba(255, 137, 156, 1) ;  */
      background:red;
      border-radius: 50%;
      /* right: 5%;
      right: 75%;
      top: 0; */
    }
    .msg-box{
      align-items:baseline;justify-content:space-between;
    }
    .to-top{
      position:fixed;right: 4%;bottom: 20%;width: 40px;height: 40px;
    }
    .fly-box{
      position: fixed;
      left: 0;right: 0;top: 0;bottom: 0;
      background: rgba(0,0,0,0.3);
      z-index:10000;
    }
    .fly-container{
        position: fixed;
        left: 0;right: 0;bottom: 0;
        background: #fff;
        z-index:10001;
      }
        /* 点击按钮放大 */
    .zoom:active{
      transform: scale(1.1,1.1)
    }
    .num-box{
      span{
        width: 24px;height: 24px;display:block;border-radius:50%;
      }
      img{
        width: 24px;height: 24px;
      }
      span:nth-child(2){
        display: inline-block;
        width: 90px;height: 24px;
        border-radius:12px;
        background:rgba(255,137,156,0.2);
        /* color:rgba(255,161,176,1); */
        text-align: center;line-height: 24px;
        margin: 0 -20px;
      }
    }
    .input{
      width: 40px;
      text-align: center;
      background: rgba(255,137,156,0.2);
      opacity:0.2;
      color:#000;
  }
  .define-btn{
      margin: 25px 0;
      background:rgba(255,137,156,1);
      font-size:16px;
      font-family:'SourceHanSansCN-Medium';
      font-weight:600;
      color:rgba(255,255,255,1);
      line-height:35px;
      height:41px;
      text-align: center;
    }
    .fly-li{
      padding:15px;
    }
    .fly-li-right{
      padding-left: 20px;
    }
</style>
<style lang="stylus" scoped>

</style>
<!-- 订单区，商品详情页 -->
<template>
  <div class="pos-relative box">
    <!-- 顶部标签 -->
    <!-- <ComHeader title="商品详情页"  leftArrow="left" class="title" style="height: 1.45rem;"/>
      <div style="height: 1.45rem;"></div> -->

    <!-- 轮播图 -->
    <div class="swiper-container" style="padding:0 !important;">
      <div class="swiper-wrapper">
        <div
          class="swiper-slide pos-relative"
          v-for="(item,index) in bannerList"
          :key="index"
        >
          <img :src="item?item.run_photo:''" />

          <!-- 轮播图底部编号 -->
          <div class="pos-absolute banner-icon">
            {{ index + 1 }}/{{ bannerList.length }}
          </div>

          <!-- 轮播图右下角图文详情 -->
          <!-- <div class="pos-absolute banner-btn" @click="fnToDetailimg">
              <img src="../../../static/new/but_details.png" >
            </div> -->
        </div>
      </div>
    </div>

    <!-- 商品信息 -->
    <div class="msg">
      <!-- 首行 -->
      <div class="msg-box flex-display">
        <!-- 价格信息 -->
        <div class="price ">
            <span>
              <img
                src="../../../static/new/huiyuanjifen.png"
                style="width: 26px;height:23px;margin-bottom: 3px;padding: 0;"/>
                <!-- {{ this.gooodsMsg ? this.gooodsMsg.new_price : "" }} -->
                <!-- {{this.gooodsMsg.goods_price}} -->
                {{fnPrice(gooodsMsg.goods_price)}}                
            </span>
          <span v-if="currentTabbar == '面膜区'">
            ¥{{ this.gooodsMsg ? this.gooodsMsg.old_price : "" }}
          </span>
        </div>
        <!-- 库存信息 -->
        <div class="stock">

          <!-- 面膜 -->
          <div v-if="currentTabbar=='面膜区'">
            <span>
              库存：{{this.gooodsMsg.inventory ? this.gooodsMsg.inventory : ""}}件
            </span>
          </div>

          <!-- 公司 -->
          <div v-if="currentTabbar=='联创下单区'&&currentStockTabbar=='公司库存'">
            <span>
              公司库存：{{this.gooodsMsg.inventory ? this.gooodsMsg.inventory : ""}}件
            </span>
          </div>

          <!-- 个人 -->
          <div v-if="currentTabbar=='联创下单区'&&currentStockTabbar=='个人库存'">
            <span>
              个人库存：{{this.gooodsMsg.inventory ? this.gooodsMsg.inventory : ""}}件
            </span>
          </div>
        </div>
      </div>

      <!-- 商品名称 -->
      <p>
        {{ this.gooodsMsg.title ? this.gooodsMsg.title : "" }}
        {{ this.gooodsMsg.units_describe ? this.gooodsMsg.units_describe : "" }}
      </p>

      <!-- 商品描述 -->
      <p>{{ this.gooodsMsg.describe ? this.gooodsMsg.describe : "" }}</p>
    </div>

    <div class="goods_title">
      商品详情
    </div>

    <!-- 详情图 -->
    <div class="detail">
      <ul>
        <li v-for="(item,index) in detailList" :key="index">
          <img :src="item.detail_photo" style="width: 100%;" />
        </li>
      </ul>
    </div>

    <!-- 回到顶部按钮 -->
    <div v-if="isshowbtn" class="to-top" @click="toTop">
      <img
        src="../../../static/new/but_top.png"
        style="width: 100%;height: 100%;"
      />
    </div>

    <!-- 弹出框 -->
    <div class="fly-box" v-if="isShowFlyBox" @click.self="isShowFlyBox = false">
      <div class="fly-container">
        <li class="fly-li">
          <!-- 商品展示 -->
          <div class="flex-display" style="margin-bottom: 20px;">

            <!-- 左侧图片 -->
            <div>
              <img :src="this.gooodsMsg.photo" style="width: 73px;height: 73px;"/>
            </div>

            <!-- 右侧文字 -->
            <div
              class="fly-li-right flex-column-between flex-num-one"
              style="width:100%;"
            >
              <div>
                <p>
                  {{ this.gooodsMsg.title ? this.gooodsMsg.title : "" }}
                  {{ this.gooodsMsg.units_describe ? this.gooodsMsg.units_describe  : "" }}
                </p>
                <!-- 商品描述 -->
                <p>
                  {{ this.gooodsMsg.describe ? this.gooodsMsg.describe : "" }}
                </p>
              </div>
              <div
                class="flex-display"
                style="justify-content:space-between;"
                v-if=" settlement == '个人出货' || settlement == '个人转让' "
              >
                <div v-if=" settlement == '个人出货' ">
                  公司库存：{{ this.gooodsMsg.inventoryCOM }}
                </div>
                <div>个人库存：{{ this.gooodsMsg.inventory }}</div>
              </div>
              <div
                v-else
                class="flex-display"
                style="justify-content:space-between;"
              >
                <div class="price" style="vertical-align: baseline">
                  <span>
                    <span
                      v-if="currentTabbar == '面膜区'"
                      style="font-size:18px"
                      >¥</span
                    >
                    <span v-else>
                      <img
                        src="../../../static/new/huiyuanjifen.png"
                        style="width: 26px;height:23px;margin-bottom: 3px;padding: 0;"
                      />
                    </span>
                    <!-- {{
                      this.gooodsMsg.new_price ? this.gooodsMsg.new_price : ""
                    }} -->
                    <!-- {{this.gooodsMsg.goods_price}} -->
                    {{fnPrice(gooodsMsg.goods_price)}}
                  </span>
                  <span v-if="currentTabbar == '面膜区'">
                    ¥{{
                      this.gooodsMsg.old_price ? this.gooodsMsg.old_price : ""
                    }}
                  </span>
                </div>
                <!-- <div style="line-height: 30px;">
                          数量：{{num}}
                        </div> -->
              </div>
            </div>
          </div>

          <!-- 数量选择 -->
          <div class="flex-row-between">
            <div>
              请选择数量
              <span
                style="color:rgba(255,161,176,1)"
                v-if="settlement == '个人出货'"
              >
                （最多出货{{ numBig }}箱）
              </span>
              <span
              style="color:rgba(255,161,176,1)"
              v-if="settlement == '个人转让'"
            >
              （最多转让{{ this.gooodsMsg.inventory }}箱）
            </span>

            </div>
            <!-- 数量选择 -->
            <div class="num-box flex-display">
              <span @click="minusNum" class="zoom">
                <img :src="num >1 ?minusUse:minusDis" />
              </span>
              <span>
                <input type="text" v-model="num" class="input" />
              </span>
              <span @click="plusNum" class="zoom">
                <img :src="num!=this.numBig?plusUse:plusDis" />
              </span>
            </div>
          </div>

          <!-- 确定按钮 -->
          <div @click="fnAddCar">
            <div class="define-btn">
              确定
            </div>
          </div>
        </li>
      </div>
    </div>
    <!-- 底部按钮 -->
    <div class="bottom-box pos-relative " :class="isbottom?'bottom-box-20':''">
      <!-- 购物飞球-->
      <div class="fly-ball"></div>

      <!-- ▲ 面膜区底部 -->
      <ul class="flex-display" v-if="this.currentTabbar == '面膜区'">
        <!-- ● 面膜区订单 -->
        <li class="flex-num-one mylist" @click="toOrderlist('面膜订单')">
          <img
            src="../../../static/new/details_tab_myorder.png"
            style="width: 22px;height:22px;"
          />
          <p>我的订单</p>
        </li>

        <!-- ● 购买 -->
        <li
          class="flex-num-one text-c buy"
          @click="fnToBuy(goods_id,goods_index,'面膜结算')"
        >
          立即购买
        </li>
      </ul>

      <!-- ▲ 公司区底部 -->
      <ul
        class="flex-display"
        v-if="this.currentTabbar == '联创下单区' && this.currentStockTabbar == '公司库存'"
      >
        <!-- ● 公司区，联创订单 -->
        <li
          class="flex-num-one mylist pos-relative"
          @click="toOrderlist('联创订单')"
        >
          <img
            src="../../../static/new/details_tab_lianchuang.png"
            style="width: 22px;height:22px;"
          />
          <div
            class="pos-absolute"
            style="right: 40%;top: 3px;width:10px;height:10px;background: rgba(255,161,176,1);border-radius: 50%;"
          ></div>
          <p id="goods-count">联创订单</p>
        </li>

        <!-- ● 进货单 -->
        <li
          class="flex-num-one text-c buy"
          @click="fnToBuy(goods_id,goods_index,'公司进货')"
        >
          添加到进货单
        </li>
      </ul>

      <!-- ▲ 个人区底部 -->
      <ul
        class="flex-display"
        v-if="this.currentTabbar == '联创下单区' && this.currentStockTabbar == '个人库存'"
      >
        <!-- ● 个人区，联创订单 -->
        <li
          class="flex-num-one mylist pos-relative"
          @click="toOrderlist('个人订单')"
        >
          <img
            src="../../../static/new/details_tab_lianchuang.png"
            style="width: 22px;height:22px;"
          />
          <!-- 徽章 -->
          <div
            class="pos-absolute"
            style="right: 38%;top: 3px;width:10px;height:10px;background: rgba(255,161,176,1);border-radius: 50%;"
          ></div>

          <p>我的订单</p>
        </li>

        <!-- ● 转让单 -->
        <li
          class="flex-num-one text-c transfer"
          @click="fnToBuy(goods_id,goods_index,'个人转让')"
        >
          添加到转让单
        </li>

        <!-- ● 出货单 -->
        <li
          class="flex-num-one text-c shipment"
          @click="fnToBuy(goods_id,goods_index,'个人出货')"
        >
          添加到出货单
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
  // 引入插件
  import { fly } from "./fly.js";
  import axios from "axios";
  import { Indicator, Toast } from "mint-ui";
  // import ComHeader from "@/common/ComHeader";
  import api from "@/fetch/api";
  import { mapState, mapGetters, mapMutations } from "vuex";

  function handleScroll(e) {
    Toast("123");
    console.log("123");
    // Toast(e.path[1].scrollY)
    // if(e.path[1].scrollY > '1000'){
    //   this.isshowbtn = true
    // }else{
    //   this.isshowbtn = false

    // }
  }

  export default {
    name: "goodsdetail",
    components: {
      // ComHeader,
      Indicator,
      Toast
    },
    data() {
      return {
        isShowFlyBox: false,
        num: 1,
        minNun: 1,
        isplus: true,
        isminus: true,
        plusDis: "../../../static/new/but_plus_dis.png",
        plusUse: "../../../static/new/but_plus_usable.png",
        minusDis: "../../../static/new/but_subtract_dis.png",
        minusUse: "../../../static/new/but_subtract_usable.png",

        // 用户信息
        wxUserInfo: this.$store.state.userInfo,

        // 商品ID
        goods_id: this.getUrlParams("goods_id"),

        // 商品索引值
        goods_index: this.getUrlParams("goods_index"),

        // 轮播图数组
        bannerList: [],

        // 商品信息数组
        gooodsMsg: [],

        // 商品详情图数组
        detailList: [],

        // 顶部tabbar，默认选中
        currentTabbar: this.$store.state.currentTabbar,

        // 库存选择
        currentStockTabbar: this.$store.state.currentStockTabbar,

        settlement: this.$store.state.settlement,

        // 是否展示回到顶部按钮
        isshowbtn: false,

        // 联创订单，数量徽章
        lcListNum: 1,

        // 是否展示动画效果
        isShowAnimation: this.$store.state.isShowAnimation,

        // 数量选择，最大值
        numBig: 0,

        // 兼容苹果，未完成
        isbottom: false,
        top:0,
        isShowToast:true,

      };
    },
    created() {
      console.log(66666)
      console.log(this.wxUserInfo)

      if(this.wxUserInfo == ''){
        this.wxUserInfo = this.getlocalStorage('wxUserInfo');
      }
      console.log(this.wxUserInfo)
      console.log(77777)
      document.title = "商品详情页";
      console.log('currentStockTabbar99999999999999',this.currentStockTabbar)
      // console.log(123, this.isWinxin());
      // Toast(this.isWinxin());
      this.isShowToast = false
      setTimeout(() => {
        this.isShowToast = true        
      }, 1000);

    },
    mounted() {

      // 获取商品轮播图
      this.fnGetBanner();

      // 获取商品信息
      this.fnGetGoodsInfo();

      // 获取商品详情图
      this.fnGetGoodsDetail();

      // 监听滚动事件？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？？
      window.addEventListener("scroll", this.handleScroll);
      // document.body.addEventListener('scroll',this.handleScroll);
      // document.addEventListener('scroll', this.handleScroll)

    },
    methods: {

      fnPrice(arr){
        console.log(12300,arr)
        console.log(12300,this.wxUserInfo.level)
        if(arr == undefined){
          return
        }
        var value;
        arr.forEach(item => {
          if (item.level == this.wxUserInfo.level) {
            value = item.price;
          }
        });
        if(!value){
          value = Number(price).toFixed(2)
        }
        return value;
      },

      /**
       * @desc    加入购物车
       * @author  ye
       * @param   none
       */
      fnAddCar() {
        var type;
        if (this.settlement == "面膜结算") {
          type = "vcmask";
        } else if (this.settlement == "公司进货") {
          type = "stock";
        } else if (this.settlement == "个人转让") {
          type = "transfer";
        } else if (this.settlement == "个人出货") {
          type = "deliver";
        }

        const params8 = {
          userid: this.wxUserInfo.id,
          goodsid: this.goods_id,
          type: type,
          goodscounts: this.num
        };
        api.addcart(params8).catch(res => {
          // 隐藏
          this.isShowFlyBox = false;

          // 改变动画效果判断
          this.$store.commit("changeIsShowAnimation", true);

          // 判断是否渲染动画效果
          this.fnShowAnimation();

          if (res.data.code == 1) {
            Toast(res.data.msg);
          }
        });
      },

      /**
       * @desc    数量操作，减法
       * @author  ye
       * @param   none
       */
      minusNum() {
        // 如果数量没有到最小值，允许减少数量
        if (this.num != this.minNun) {
          this.num--;
        } else {
          Toast({
            message: "到底啦",
            duration: 1000
          });
        }
      },

      /**
       * @desc    数量操作，加法
       * @author  ye
       * @param   none
       */
      plusNum() {
        // 如果数量没有到最大值，允许添加
        if (this.num < this.numBig) {
          this.num++;
        } else {
          Toast("商品数量不能超过" + this.numBig + "件");
        }
      },

      /**
       * @desc    判断是否渲染动画效果
       * @author  ye
       * @param   none
       */
      fnShowAnimation() {
        var left;
        if (this.settlement == "面膜结算") {
          left = 250;
        } else if (this.settlement == "公司进货") {
          left = 250;
        } else if (this.settlement == "个人出货") {
          left = 250;
        } else if (this.settlement == "个人转让") {
          left = 150;
        }

        // 渲染时,如果为true,则渲染动画效果
        if (this.$store.state.isShowAnimation === true) {
          // 兼容
          setTimeout(() => {
            fly(left);
          }, 300);

          setTimeout(() => {
            fly(left);
          }, 310);

          // 重置动画
          this.$store.commit("changeIsShowAnimation", false);
        }
      },

      /**
       * @desc    跳转到订单列表
       * @author  ye
       * @param   none
       */
      toOrderlist() {
        this.$router.push({
          path: "/orderlist"
        });
      },

      /**
       * @desc    购买按钮
       * @author  ye
       * @param   {id,index,type},id，商品的ID，index，商品是数组的索引值，type，改变结算类型
       */
      fnToBuy(id, index, type) {
        // 显示弹窗
        this.isShowFlyBox = true;

        //  改变仓库结算类型
        this.$store.commit("changeSettlement", type);

        // 重新获取数值
        this.settlement = this.$store.state.settlement;
      },

      /**
       * @desc    获取轮播图数据
       * @author  ye
       * @param   none
       */
      fnGetBanner() {
        const params = {
          userid: this.wxUserInfo.id,
          type: "runp",
          goods_id: this.goods_id
        };
        api.getGoodsInfo(params).catch(res => {
          this.bannerlist = res.data;
          for (let item of res.data) {
            this.bannerList.push(item);
          }
          this.$nextTick(() => {
            new Swiper(".swiper-container", {
              loop: true,
              grabCursor: true,
              centeredSlides: true,
              slidesPerView: "auto",
              coverflowEffect: {
                rotate: 40,
                stretch: 0,
                depth: 100,
                modifier: 1,
                slideShadows: true
              },
              autoplay: {
                delay: 3000, //切换时间，默认三秒
                stopOnLastSlide: false, //默认false，如为true，到最后停止切换
                disableOnInteraction: false, //人为滑动后，是否停止，默认停止true
                waitForTransition: true
              }
            });
          });
        });
      },

      /**
       * @desc    商品信息
       * @author  ye
       * @param   none
       */
      fnGetGoodsInfo() {
        var type;
        // 获取面膜区商品
        if (this.currentTabbar == "面膜区") {
          type = "mm";
          // 获取公司区商品
        } else if (
          this.currentTabbar == "联创下单区" &&
          this.currentStockTabbar == "公司库存"
        ) {
          type = "lc";
          // 获取个人区商品
        } else if (
          this.currentTabbar == "联创下单区" &&
          this.currentStockTabbar == "个人库存"
        ) {
          type = "one";
        }

        const params3 = {
          userid: this.wxUserInfo.id,
          type: type
        };
        api.getGoodsInfo(params3).catch(res => {
          console.log('gooodsMsg',res)
          if (res.data.code != 0) {
            if (res.data[this.goods_index].id == this.goods_id) {
              this.gooodsMsg = res.data[this.goods_index];
            }
          }

          if (
            this.currentTabbar == "联创下单区" &&
            this.currentStockTabbar == "个人库存"
          ) {
            // 个人区，保留两个库存
            this.gooodsMsg = res.data[this.goods_index].goods;
            this.gooodsMsg.inventoryCOM = this.gooodsMsg.inventory;
            this.gooodsMsg.inventory = res.data[this.goods_index].m_inventory;
          }

          // console.log("this.gooodsMsg", this.gooodsMsg);
          // 兼容，如果没有公司库存，则最小的是个人库存，如果有公司库存，则比较两个大小
          if (!this.gooodsMsg.inventoryCOM) {
            this.numBig = this.gooodsMsg.inventory;
          } else {
            this.numBig = Math.min(
              this.gooodsMsg.inventoryCOM,
              this.gooodsMsg.inventory
            );
          }

        });
      },

      /**
       * @desc    详情图
       * @author  ye
       * @param   none
       */
      fnGetGoodsDetail() {
        const params2 = {
          userid: this.wxUserInfo.id,
          type: "detailp",
          goods_id: this.goods_id
        };

        // 获取轮播图数据
        api.getGoodsInfo(params2).catch(res => {
          this.detailList = res.data;
        });
      },

      /**
       * @desc    回到顶部
       * @author  ye
       * @param   none
       */
      toTop(e) {
        var timer = setInterval(() => {
          this.top = this.top*0.8

          document.documentElement.scrollTop = this.top  
          window.pageYOffset = this.top 
          document.body.scrollTop = this.top 
              
          if(this.top<=20){
            document.documentElement.scrollTop = 0;
            window.pageYOffset = 0;
            document.body.scrollTop = 0;
            clearInterval(timer)
          }  
        }, 30);
      },

      /**
       * @desc    滚动事件，检测位置，判断是否宣誓按钮
       * @author  ye
       * @param   {e},e，事件的位置
       */
      handleScroll(e) {
        this.top = e.path[1].scrollY
        if (e.path[1].scrollY > "1000") {
          this.isshowbtn = true;
        } else {
          this.isshowbtn = false;
        }
      },

      /**
       * @desc    从轮播图滚动到详情图
       * @author  ye
       * @param   none
       */
      fnToDetailimg() {
        setTimeout(function() {
          document.documentElement.scrollTop = 480;
        }, 500);
      }
    },
        // 监听两个tabbar的数据
    watch: {
      num: {
        immediate: true,
        deep: true,
        handler(new_val, old_val) {
          console.log(123,new_val, old_val)
          if(new_val != '0' && old_val != '1' ){
            setTimeout(() => {
               if(new_val>this.numBig){
                  this.num = this.numBig
                  if(this.isShowToast){
                    Toast("商品数量不能超过" + this.numBig + "件");
                  }
                }
            }, 1000);
          }
        }
      }
    }
  };
</script>
